<%@ page language="java" import="java.util.*,dao.*,entity.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'students.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<style type="text/css">
	table tr:nth-child(even){
		background-color: darkgray;
	}
	</style>
  </head>
  
  <body>
<%@include file="/checkLogin.jsp" %>
  <h1>学生列表</h1>
     <a href="addStuServlet">增加新学员</a>
     <table border="1" align="center" width="80%" cellpadding="0" cellspacing="0">
     	<tr>
     	<td>学号</td><td>姓名</td><td>手机号</td><td>年级</td><td>删除</td>
     	</tr>
     	<%
     	  StudentDaoI sdao=new StudentDao();
     	  int pageNo=1;//显示的页号
     	  try{
     	    pageNo=Integer.parseInt(request.getParameter("p"));
     	    pageNo=pageNo<1?1:pageNo;
     	  }catch(Exception e){}
     	  
     	  List<Student> list=sdao.paging(10, pageNo);
     	  int totalPages=sdao.getTotalPage();
     	  for(Student s:list){
     	 %>
     	 <tr>
     	<td><%=s.getStuno()%></td><td><%=s.getSname()%></td><td><%=s.getTelephone()%></td><td><%=s.getGradeId()%></td>
     	<td>
     	<a href="8-28/stus/delStudent.jsp?stuno=<%=s.getStuno()%>" onclick="return confirm('真的要删除？');">删除</a>
     	<a href="8-28/stus/updateStudent.jsp?stuno=<%=s.getStuno()%>">修改</a>
     	<a href="showStudent?stuno=<%=s.getStuno()%>">查看详细信息</a>
     	
     	</td>
     	</tr>  
     	 <%} %>
     </table>
     <p align="center">
     <a href="8-28/stus/students.jsp?p=1">首页</a>
     <% if(pageNo>1){ %>
       <a href="8-28/stus/students.jsp?p=<%=pageNo-1%>">上一页</a>
      <%} %>
      <span><%=pageNo%></span>
       <%if(pageNo<totalPages){ %>
       <a href="8-28/stus/students.jsp?p=<%=pageNo+1%>">下一页</a>
       <%} %>
       <a href="8-28/stus/students.jsp?p=<%=totalPages%>">最后一页</a>
     </p>
     <div>
     <a href="reg.jsp">上次的案例</a>
      <img src="images/yuenan.jpg"/>
     </div>
  </body>
</html>
